package com.java;

/**
 * 懒汉式
 */
public class SingletonTest2 {
    public static void main(String[] args) {
        Person p1 = Person.getInstance();
        Person p2 = Person.getInstance();
        System.out.println(p1 == p2);
    }
}

class Person{

    private Person(){

    }


    private static Person instance = null;

    public static Person getInstance(){
        if(instance == null){
            instance = new Person();
        }
        return instance;
    }
}
